#include "front/text_normalize.h"

using namespace std;
using namespace ppspeech;

const wregex mcWregexLetterDecimal(L"[a-zA-Z]\\d+\\.\\d+");

void TextNormalizer::TnReLetterDecimal(wstring* fpInWsentence, const LanguageEnum fcInLanguage)
{
	wsmatch tWsmatch;

	while(regex_search(*fpInWsentence, tWsmatch, mcWregexLetterDecimal))
	{
		string tInSentence = wstring2utf8string(*fpInWsentence);
		wstring tWstrMatch = tWsmatch[0];	//匹配到字母+小数的字符串
		wstring tWstrLetters = L"";
		wstring tWstrNumbers = L"";
		for(const wchar_t tcWchar: tWstrMatch) {
			if( IsWcharEnLetter(tcWchar) ) {
				tWstrLetters += tcWchar;
			}
			else if( IsWcharNumber(tcWchar) || tcWchar == L'.' ) {
				tWstrNumbers += tcWchar;
			}
		}

		wstring tWstrReplace = tWstrLetters + L" " + tWstrNumbers;

		WstrReplacePosition(fpInWsentence, tWsmatch.position(0), tWsmatch.length(0), tWstrReplace);
	}
}
